// part1:C12:ex12.26.cpp
// use allocator.
#include <cstddef>
#include <iostream>
#include <string>
#include <memory>
using namespace std;

int main(int argc, char **argv)
{
  allocator<string> alloc;
  auto const ptr = alloc.allocate(100);
  string s1;
  string *qtr = ptr;

  while (cin >> s1 && qtr != ptr)
  {
    alloc.construct(qtr++, s1);  
  }

  const size_t size = qtr - ptr;

  for (size_t i = 0; i < size; i++)
  {
    cout << ptr[i] << " " << endl;  
  }

  while (qtr != ptr)
  {
    alloc.destroy(--qtr);
    
  }

  alloc.deallocate(ptr, 100);

  return 0;
}
